package com.yxym.bignum;

import java.math.BigDecimal;
import java.math.BigInteger;

public class BigInteger_ {
    public static void main(String[] args) {
        BigInteger bigInteger = new BigInteger("646941626");
        System.out.println(bigInteger);
        BigInteger bigInteger1 = new BigInteger("1514851");
        //1.对BigInteger进行加减乘除，
        //2.可以创建一个要操作的BigInteger然后进行相关的操作
        BigInteger add = bigInteger.add(bigInteger1);
        System.out.println(add);//+
        BigInteger subtract = bigInteger.subtract(bigInteger1);
        System.out.println(subtract);//-
        BigInteger multiply  = bigInteger.multiply(bigInteger1);
        System.out.println(multiply);//*
        BigInteger divide = bigInteger.divide(bigInteger1);
        System.out.println(divide);//\
        BigDecimal bigDecimal = new BigDecimal("5686535.541");
        BigDecimal bigDecimal1 =new BigDecimal("54654151.1454");
        System.out.println(bigDecimal);
        System.out.println(bigDecimal.add(bigDecimal1));
        System.out.println(bigDecimal.subtract(bigDecimal1));
     //   System.out.println(bigDecimal.divide(bigDecimal1));
        //可能抛出异常,调用方法时，指定精度，保留分子的精度
        System.out.println(bigDecimal.divide(bigDecimal1,BigDecimal.ROUND_CEILING));

    }
}
